
package net.jbaez.code;

/*
 * Copyright 2008 DynamiCode 
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 *
 * http://www.apache.org/licenses/LICENSE-2.0 
 *
 * Unless required by applicable law or agreed to in writing, 
 * software distributed under the License is distributed on an 
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
 * either express or implied. See the License for the specific 
 * language governing permissions and limitations under the License. 
 */
/**
 * Clase que representa la declaracion
 * de una interfaz Java
 */
public class JInterface extends JAnnotatedElement implements ITypeElement<JInterface>{

    	//Tipo de la clase
    	private IType<JInterface> type = new JInterfaceType(this);
    
    	/**
    	 * Crea una instancia de una interfaz
    	 * @param name Nombre de la interfaz
    	 * @throws IllegalArgumentException Si el nombre pasado
    	 * no es un nombre valido
    	 */
    	public JInterface(String name){
    	    setName(name);
    	}
    	
	@Override
	public IType<JInterface> getType() {
		return type;
	}
	
	/**
	 * Clase utilizada para implementar
	 * la interfaz Itype
	 */
	private static final class JInterfaceType implements IType<JInterface>{
	    //Referencia a la interface
	    private JInterface jInterface;
	    
	    public JInterfaceType(JInterface jInterface){
		this.jInterface = jInterface;
	    }
	    
	    public boolean equals(Object obj){
		if (obj instanceof JInterface) {
		    JInterfaceType i = (JInterfaceType) obj;
		    return i.jInterface == jInterface;
		}else{
		    return false;
		}
	    }
	}
}
